﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using LogicTree.Interfaces;

namespace LogicTree
{
    public class Conjunction<T>
    {
        public Conjunction()
        {
            Conjuncts = new List<IBooleanEntity<T>>();
        }
        public List<IBooleanEntity<T>> Conjuncts { get; set; }
        public override string ToString()
        {
            
            string statement = "";
            if (Conjuncts.Count > 0)
            {
                if(!Conjuncts[0].Value)
                    statement = "!" + Conjuncts[0].FeatureName;
                else 
                    statement = Conjuncts[0].FeatureName;
            }

            for (int i = 1; i < Conjuncts.Count;i++ )
            {
                if (!Conjuncts[i].Value)
                    statement += " & !" + Conjuncts[i].FeatureName;
                else
                    statement += " & " + Conjuncts[i].FeatureName;
            }
            return statement;
        }
    }
}
